<style>
    .layui-form-item .layui-input-company {width: auto;padding-right: 10px;line-height: 38px;}
</style>
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main">
        <div class="layui-form layuimini-form">
            <div class="layui-form-item">
                <label class="layui-form-label required" >用户角色</label>
                <div class="layui-input-block">
                    <select name="roleID" lay-filter="aihao">
                        <option value=""></option>
                        {{range .role}}
                        <option value="{{.Id}}">{{.RoleName}}</option>
                        {{end}}
                    </select>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label required">用户账号</label>
                <div class="layui-input-block">
                    <input type="text" name="username" value="{{.user.UserName}}" lay-verify="required" lay-reqtext="用户账号不能为空" placeholder="请输入英文用户名"   class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">真实姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="truename" value="{{.user.TrueName}}" lay-verify="required" lay-reqtext="真实姓名不能为空" placeholder="请输入真实姓名"   class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">手机号</label>
                <div class="layui-input-block">
                    <input type="text" name="phone" value="{{.user.Phone}}" lay-verify="required|phone" lay-reqtext="手机号不能为空" placeholder="请输入手机号"   class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="email" value="{{.user.Email}}" lay-verify="required|email" lay-reqtext="邮箱不能为空" placeholder="请输入邮箱"   class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">年龄</label>
                <div class="layui-input-block">
                    <input type="text" name="age" value="{{.user.Age}}" lay-verify="required" lay-reqtext="年龄不能为空" placeholder="请输入年龄"   class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="gender" value="1" title="男" {{if eq .user.Gender 1}}checked{{end}}>
                    <input type="radio" name="gender" value="2" title="女" {{if eq .user.Gender 2}}checked{{end}}>
                    <input type="radio" name="gender" value="3" title="保密" {{if eq .user.Gender 3}}checked{{end}}>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否开启</label>
                <div class="layui-input-block">
                    <input type="checkbox" {{if eq .user.IsActive 1}}checked {{end}} name="is_active"  lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">地址</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入地址" name="address" class="layui-textarea">{{.user.Address}}</textarea>
                </div>
            </div>

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" name="mark" class="layui-textarea">{{.user.Mark}}</textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <input type="hidden" id="Id" name="Id" value="{{.user.Id}}">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="setting">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form','jquery'], function () {
        var form = layui.form
            , layer = layui.layer
            ,$ = layui.jquery;


        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        //监听提交
        form.on('submit(setting)', function (data) {

            //获取
            ajaxs("/sys/UpdateUser",data.field,function(res){
                layer.msg(res["Msg"], function () {
                    layer.closeAll()
                });
            },function(res){
                layer.msg(res["Msg"]);
            })
        });

    });
</script>